package com.aind.common.pager;

public class Pager {
    public static final String PAGESIZE = "pageSize";
    public static final String CURRENT_PAGE = "currentPage";
    public static final String TOTAL = "total";
    public static final String PAGER_VAR = "pager";
    private int pageSize;
    private int currentPage;
    private int totalPages;
    private int total;

    public Pager() {
    }

    public int getCurrentPage() {
        return this.currentPage;
    }

    public int getTotalPages() {
        if(this.total % this.pageSize == 0) {
            this.totalPages = this.total / this.pageSize;
        } else {
            this.totalPages = this.total / this.pageSize + 1;
        }

        return this.totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getStart() {
        return this.pageSize * (this.currentPage > 0?this.currentPage - 1:0);
    }

    public int getTotal() {
        return this.total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}